home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
pckey.exe
/
PCKEY.DOC
< prev
next >
Wrap
Text File
|
1991-07-30
|
8KB
|
241 lines
PCKey for Borland C++
=====================
Thank you for downloading pckey.zip! I hope you find it
useful and a big time saver. It is one of many in a
series of Freeware tools from PSW.
I used Peter Norton's "Programmer's Guide to the IBM PC &
PS/2", copyright 1988, published by Microsoft press, as the
only reference in coding pckey.
The PCKey class provides access to the PC's keyboard through
fast inline member functions. Special characters are
defined in the header for your convenience. PCKey is not
for use in Windows 3.0 programming -- use only for DOS
applications! I have tested PCKey with Borland C++ version
2.0 on a PC with Award Software's 386 Modular BIOS version
3.03a. If you have problems running the demo please note
your machine's BIOS manufacturer and version/copyright and
the nature of the problem and let me know by email, phone,
or postcard. I will make every effort to support PCKey on
as many machines as is practical (everyone benefits from
user supported freeware). You can port PCKey to other
compilers by changing from Borland's inline pseudo variables
to whatever style is provided by your compiler. As a last
resort you can convert to int86() bios calls. Most
compilers are being forced by the more efficient Borland
inline assembly standard to upgrade.
Compile and run fastkey.cpp to set your keyboard's fastest
typematic rate/delay. A project file for the IDE is
provided.
Compile pckeyd.cpp and pckey.cpp. Then link and run
pckeyd.exe to test the pckey.cpp module. A project file is
provided for this also. Study the code in pckeyd.cpp for an
example of using the PCKey class.
Never instantiate any instance of the PCKey class. There
needs to be only one instance and that is done for you
automatically. The only instance of the PCKey class is
"PCK". Its global contructor determines whether or not an
enhanced/extended keyboard is available. Also, the
typematic rate is set to the fast rate possible for quick
keyboard response in your program.
Member functions of the PCKey class are available via the
instance "PCK":
PCK.enhanced() returns true if an extended keyboard is
detected.
PCK.ascii() returns the ascii code of the last
character read by PCK.getch(),
PCK.getkey() or PCK.kbhit().
PCK.scan() returns the scan code of the last
character read by PCK.getch(),
PCK.getkey() or PCK.kbhit().
PCK.getch() Returns the ascii code of the character
read. Automatically calls extended BIOS
service for enhanced keyboards.
PCK.getkey() Returns ascii code of regular characters
and the negative of the scan code for
special characters.
PCK.kbhit() Returns true if key stroke is waiting.
PCK.shift() returns the keyboard status flags.
Automatically calls extended BIOS service
for enhanced keyboards.
The following boolean functions should be self explanatory.
PCK.InsertStateActive()
PCK.CapsLockActive()
PCK.NumLockActive()
PCK.ScrollLockActive()
PCK.AltPressed()
PCK.CtrlPressed()
PCK.LeftShiftPressed()
PCK.RightShiftPressed()
PCK.ShiftPressed()
( The next group is automatically enabled
for enhanced keyboards )
PCK.SysReqPressed()
PCK.CapsLockPressed()
PCK.NumLockPressed()
PCK.ScrollLockPressed()
PCK.RightAltPressed()
PCK.RightCtrlPressed()
PCK.LeftAltPressed()
PCK.LeftCtrlPressed()
PCK.setTypeMatic() sets typematic rate/delay. The default
parameters are set for the PC's default
rate.
PCK.fastTypeMatic() sets the typematic rate to the fastest
available on the host machine. PCK's
global constructor calls this function.
PCK.fastTypeMaticOnExit() sets a flag so that the global
destructor calls fastTypeMatic() instead
of setTypeMatic() for the default rate.
PCK.putch() writes asciiScanCode pair to keyboard
buffer.
PCK.flush() flushes the keyboard buffer.
The following code fragment demonstrates using the defined
keys in pckey.hpp:
switch (PCK.getch()) {
case ExtendKey:
case 0: switch(PCK.scan()) {
case F1:
...
break;
case AltM:
...
break;
case Home:
...
break;
case CtrlLArr:
...
break;
}
break;
case ESC:
...
break;
case CR:
...
break;
default:
ch = PCK.ascii();
...
break;
}
If you use PCK.getkey() the code would be:
switch (PCK.getkey()) {
case -F1:
...
break;
case -AltM:
...
break;
case -Home:
...
break;
case -CtrlLArr:
...
break;
case ESC:
...
break;
case CR:
...
break;
default:
ch = PCK.ascii();
...
break;
}
I think you get the idea. Just lookup the key you want in
pckey.hpp. If it's a special key then PCK.getch() returns
zero or "ExtendKey" and you read the scan code from
PCK.scan(). Be sure to read the comments for ExtendKey near
the beginning of pckey.hpp. Your comments and questions are
always welcome. John
----------------end-of-author's-documentation---------------
Software Library Information:
This disk copy provided as a service of
Public (software) Library
We are not the authors of this program, nor are we associated
with the author in any way other than as a distributor of the
program in accordance with the author's terms of distribution.
Please direct shareware payments and specific questions about
this program to the author of the program, whose name appears
elsewhere in this documentation. If you have trouble getting
in touch with the author, we will do whatever we can to help
you with your questions. All programs have been tested and do
run. To report problems, please use the form that is in the
file PROBLEM.DOC on many of our disks or in other written for-
mat with screen printouts, if possible. PsL cannot debug pro-
programs over the telephone, though we can answer questions.
Disks in the PsL are updated monthly, so if you did not get
this disk directly from the PsL, you should be aware that the
files in this set may no longer be the current versions. Also,
if you got this disk from another vendor and are having prob-
lems, be aware that some files may have become corrupted or
lost by that vendor. Get a current, working disk from PsL.
For a copy of the latest monthly software library newsletter
and a list of the 3,000+ disks in the library, call or write
Public (software) Library
P.O.Box 35705 - F
Houston, TX 77235-5705
Orders only:
1-800-2424-PSL
MC/Visa/AmEx/Discover
Outside of U.S. or in Texas
or for general information,
Call 1-713-524-6394
PsL also has an outstanding
catalog for the Macintosh.